#ifndef SCENE_GRAPH_VISITOR_H_
#define SCENE_GRAPH_VISITOR_H_

#include "SceneGraphNode.h"

class SceneGraphVisitor
{
	/*
	** SceneGraphVisitor is a tree visiting class that
	** visits each of the nodes in the tree 
	*/

public:
	SceneGraphVisitor()
	{
	}
	
	virtual ~SceneGraphVisitor()
	{
	}
	
	void visitAll(SceneGraphNode * node)
	{
		visit(node);
		
		// get the children of the node
		irr::core::list<SceneGraphNode*> children = 
			node->getChildren();
		
		// go through all the children
		for (irr::core::list<SceneGraphNode*>::Iterator iter = children.begin();
			iter != children.end(); iter++)
		{
			// visit each child node
			visitAll(*iter);
		}
		
	}
	
	virtual inline void visit(SceneGraphNode * node)
	{
		// update the absolute transform of each node
		// since visit is called on the parent before
		// the children, this method should work.
		node->updateAbsTransform();
	}
};

#endif
